package org.cunamas.core.dao.impl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.sql.DataSource;

import org.cunamas.core.dao.AsistenciaGrupoEtareoDao;
import org.cunamas.core.dao.AtencionIntegralTallaEdadDao;
import org.cunamas.core.dao.CoberturaAtencionDao;
import org.cunamas.core.dto.AsistenciaGrupoEtareoDto;
import org.cunamas.core.dto.GraficoBarrasDto;
import org.cunamas.core.dto.CoberturaAtencionDto;
import org.cunamas.core.dto.Filtros;
import org.cunamas.core.dto.mapper.AsistenciaGrupoEtareoMapper;
import org.cunamas.core.dto.mapper.AtencionIntegralTallaEdadMapper;
import org.cunamas.core.dto.mapper.CoberturaAtencionMapper;
import org.cunamas.web.util.CunamasConstants;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlReturnResultSet;
import org.springframework.jdbc.object.StoredProcedure;
import org.springframework.stereotype.Component;

@Component
public class AtencionIntegralTallaEdadDaoProcedureImpl extends StoredProcedure implements AtencionIntegralTallaEdadDao {

	public static final String SPROC_NAME = "SP_IND_ATENCION_INTEGRAL_TALLA_EDAD";
	
	public static final String V_CODPRG = "V_CODPRG";
	public static final String V_UBIGEO = "V_UBIGEO";
	public static final String V_SEDE = "V_GSEDE";
	public static final String V_CODCOM = "V_CODCOM";
	public static final String V_ANIO = "V_ANIO";
	public static final String V_MES = "V_MES";
	
	@Inject
	public AtencionIntegralTallaEdadDaoProcedureImpl(DataSource dataSource){
		super(dataSource, SPROC_NAME);
		declareParameter(new SqlReturnResultSet("rs", new AtencionIntegralTallaEdadMapper()));
		declareParameter(new SqlParameter(V_CODPRG, Types.VARCHAR));
	    declareParameter(new SqlParameter(V_UBIGEO, Types.VARCHAR));
	    declareParameter(new SqlParameter(V_SEDE, Types.VARCHAR));
	    declareParameter(new SqlParameter(V_CODCOM, Types.VARCHAR));
	    declareParameter(new SqlParameter(V_ANIO, Types.VARCHAR));
	    declareParameter(new SqlParameter(V_MES, Types.VARCHAR));
	    compile();
	}
	
	

	public List<GraficoBarrasDto> retornaAtencionIntegralPesoTalla(Filtros filtros){
		Map<String, Object> inputs = new HashMap<String, Object>();
		inputs.put(V_CODPRG, CunamasConstants.COD_PROG);
		inputs.put(V_UBIGEO, filtros.getUbigeo());
	    inputs.put(V_SEDE, filtros.getSede());
	    inputs.put(V_CODCOM, filtros.getSede());
	    inputs.put(V_ANIO, filtros.getAnio());	
	    inputs.put(V_MES, filtros.getMes());
	    System.out.println("PARAMETROS"+inputs);
	    Map output= super.execute(inputs);
		return (ArrayList<GraficoBarrasDto>)output.get("rs");
	}
	
	
}
